package com.lesso.yzh.sunflower.domain.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.lesso.yzh.sunflower.domain.repository.EmployeeRepository;
import com.lesso.yzh.sunflower.infra.assembler.EmployeeAssembler;
import com.lesso.yzh.sunflower.pojo.dto.EmployeeDTO;
import com.lesso.yzh.sunflower.pojo.dto.EmployeeQueryDTO;
import com.lesso.yzh.sunflower.pojo.dto.EmployeeUpdateDTO;
import com.lesso.yzh.sunflower.pojo.vo.EmployeeVO;
import org.springframework.stereotype.Service;

/**
 * EmployeeDomainService
 *
 * @author yzh
 * @since 2025-07-02
 */
@Service
public class EmployeeDomainService {

    private final EmployeeRepository employeeRepository;

    public EmployeeDomainService(EmployeeRepository employeeRepository) {
        this.employeeRepository = employeeRepository;
    }

    public Integer save(EmployeeDTO dto) {
        return employeeRepository.save(EmployeeAssembler.INSTANCE.dtoToEntity(dto));
    }
    public Integer update(EmployeeUpdateDTO dto) {
        return employeeRepository.update(EmployeeAssembler.INSTANCE.dtoToUpdateEntity(dto));
    }
    public Page<EmployeeVO> page(EmployeeQueryDTO dto) {
        return employeeRepository.getPageList(dto);
    }

    public Page<EmployeeVO> customPage(EmployeeQueryDTO dto) {
        return employeeRepository.getCustomPageList(dto);
    }

    public void deleteById(Long id) {
        employeeRepository.removeById(id);
    }
}
